﻿<Window x:Class="Vision.VisionWorkshop.Windows.ActivityOpen"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:common="clr-namespace:Vision.VisionWorkshop.Common"
        Title="Activity Open" Height="300" Width="580" ResizeMode="CanResizeWithGrip" WindowStyle="ToolWindow" Loaded="Window_Loaded">
    <Window.Resources>
        <common:OrderByConverter x:Key="OrderByConverter" />
        
        <Style x:Key="itemstyle" TargetType="{x:Type ListViewItem}">
            <EventSetter Event="MouseDoubleClick" Handler="lvActivities_ItemDoubleClick" />
        </Style>

        <Storyboard x:Key="sbLoading" BeginTime="00:00:00" Duration="00:00:01" RepeatBehavior="Forever">
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="brdLoading" Storyboard.TargetProperty="(UIElement.Visibility)">
                <ObjectAnimationUsingKeyFrames.KeyFrames>
                    <DiscreteObjectKeyFrame KeyTime="00:00:00">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames.KeyFrames>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="tbkLoadingDot1" Storyboard.TargetProperty="(UIElement.Visibility)">
                <ObjectAnimationUsingKeyFrames.KeyFrames>
                    <DiscreteObjectKeyFrame KeyTime="00:00:00.250">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="00:00:01">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames.KeyFrames>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="tbkLoadingDot2" Storyboard.TargetProperty="(UIElement.Visibility)">
                <ObjectAnimationUsingKeyFrames.KeyFrames>
                    <DiscreteObjectKeyFrame KeyTime="00:00:00.500">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="00:00:01">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames.KeyFrames>
            </ObjectAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="tbkLoadingDot3" Storyboard.TargetProperty="(UIElement.Visibility)">
                <ObjectAnimationUsingKeyFrames.KeyFrames>
                    <DiscreteObjectKeyFrame KeyTime="00:00:00.750">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                    <DiscreteObjectKeyFrame KeyTime="00:00:01">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames.KeyFrames>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </Window.Resources>
    <Grid>
        <Grid Margin="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="30*"/>
                <ColumnDefinition Width="70*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="40"/>
            </Grid.RowDefinitions>

            <TreeView Grid.Column="0" Grid.Row="0" Margin="4" x:Name="tvActivities" SelectedItemChanged="tvActivities_SelectedItemChanged">
                <TreeView.ItemTemplate>
                    <HierarchicalDataTemplate ItemsSource="{Binding Path=Folders, Converter={StaticResource OrderByConverter}, ConverterParameter='Name'}">
                        <TextBlock Text="{Binding Path=Name}" />
                    </HierarchicalDataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>
            <ListView Grid.Column="1" Grid.Row="0" Margin="4" x:Name="lvActivities" ItemContainerStyle="{StaticResource itemstyle}">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}"/>
                        <GridViewColumn Header="Description"  DisplayMemberBinding="{Binding Description}" />
                        <GridViewColumn Header="Key"  DisplayMemberBinding="{Binding Key}"/>
                    </GridView>
                </ListView.View>
            </ListView>

            <StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal">
                <Button Content="Ok" x:Name="btnOk" Height="22" Width="60" Margin="4" Click="btnOk_Click" />
                <Button Content="Cancel" x:Name="btnCancel" Height="22" Width="60" Margin="4" Click="btnCancel_Click" />
            </StackPanel>
        </Grid>

        <!-- Loading -->
        <Border x:Name="brdLoading" Background="#4C000000" Visibility="Collapsed">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                <TextBlock Text="Loading" Foreground="White" FontSize="20" />
                <StackPanel Orientation="Horizontal" Width="26">
                    <TextBlock x:Name="tbkLoadingDot1" Text="." Foreground="White" FontSize="20" Margin="2,0,0,0" Visibility="Collapsed" />
                    <TextBlock x:Name="tbkLoadingDot2" Text="." Foreground="White" FontSize="20" Margin="2,0,0,0" Visibility="Collapsed" />
                    <TextBlock x:Name="tbkLoadingDot3" Text="." Foreground="White" FontSize="20" Margin="2,0,0,0" Visibility="Collapsed" />
                </StackPanel>
            </StackPanel>
        </Border>
    </Grid>
</Window>
